import httpUtils from "./XmlHttpTool";
var bageItem = cc.Class({
    name: 'bageItem',
    properties: {

        rankName:cc.String,
        rankheadimage:cc.Integer,
        status:cc.String
      
    }
});


cc.Class({
    extends: cc.Component,

    properties: {
        
        items: {
            default: [],
            type: bageItem
        },
        itemPrefab: cc.Prefab,
        bageAllScrollView:cc.Node,
        nothingSprites:cc.Node,
        bageCloseBtn:cc.Button

    },


    closeClick:function(){


        var changebig = cc.scaleTo(0.02,1.2);

        var finish = cc.callFunc(function(){
    
            var that=this
          var changesmail = cc.scaleTo(0.08,1.0);

          var smaillfinish=cc.callFunc(function(){

            that.bageAllScrollView.active=false

          })

          var seq2 = cc.sequence(changesmail,smaillfinish)
          this.bageCloseBtn.node.runAction(seq2)
       

       }, this);
    
       var seq = cc.sequence(changebig,finish)

       this.bageCloseBtn.node.runAction(seq)

    

    },

    onLoad () {

         

    },

    init(){

        if(this.items.length>0){
            this.node.removeAllChildren();
        }
        
        var that=this
        httpUtils.NhttpPost("/marmot/user_prize",{},function(res){
            console.log("奖品列表",res)
            that.items=res
            if(that.items.length==0){
                that.nothingSprites.active=true
            }
            for (var i = 0; i < that.items.length; ++i) {
              
                var item = cc.instantiate(that.itemPrefab);
                that.node.addChild(item);
                item.getComponent('bagePrefab').init(that.items[i]);
             
            }
           
        })

    },

    start () {

    }


});
